var systemUrl="http://www.dengluyi.com:8080";
var cardno="";
var jiazaiflag=0;
var zhuanzhangflag=0;
var zhuanruyinhang="";
var sheng="";
var shi="";
var zhihang="";
var bizhong="";
var zhuanruzhanghao="";
var zhuanchuhuming="";
var zhuanruhuming="";
var zhuanzhangjine="";
var zhuanzhangyongtu="";
var tianjiazhanghu="";
var rixiane="";
var keyongyue="";
var zhuanzhangmima="";
//$(document).on("pagebeforeload",function(event,data){
//	event.preventDefault();
//	var url=data.url;
//	var uri1=url.substring(0,url.lastIndexOf("/"));
//	var uri2=url.substring(url.lastIndexOf("."));
//	var uri=url.substring(url.lastIndexOf("/"),url.lastIndexOf("."));
//	if(uri=="/zhyecx"||uri=="/zhgl"||uri=="/jymxcx"||uri=="/zzmxcx"||uri=="/skzhgl"||uri=="/dlmmxg"||uri=="/zzhk"){
//		if(cardno==""){
//			data.url=uri1+"/denglu"+uri2;
//		}
//	}
//	event.reject();
//});

$(document).on("pageload",function(event,data1){
	var url=data1.url;
	var uri=url.substring(url.lastIndexOf("/"),url.lastIndexOf("."));
	if(uri=="/zhyecx"||uri=="/zhgl"||uri=="/jymxcx"||uri=="/zzmxcx"){
		cardno="";
	$.ajax({
		url:systemUrl+"/Spring3HibernateMaven/yonghuziliao/toyecx.mobile",
		type:"get",
		dataType:"json",
		success:function(data){
			if(data.flag==true){
				cardno=data.msg.zhdh;
				$(".zh").find("span.ui-btn-text").prepend(data.msg.zhdh+" "+data.msg.khmc);
				$(".xx li:eq(0)").append(data.msg.yddh);
				$(".xx li:eq(2)").append(data.msg.zz_ed);
				$(".xx li:eq(3)").append(data.msg.dz);
			}else{
				$(".zh").html(data.msg);
				$(".xx").empty();
			}
		},
		error:function(data){
			alert("123");
		}
	});
	return cardno;
	}else if(uri=="/zhyelb"){
		$.ajax({
			url:systemUrl+"/Spring3HibernateMaven/yonghuziliao/yecx.mobile",
			type:"post",
			async:false,
			data:{"cardno":cardno},
			dataType:"json",
			success:function(data){
				if(data.flag==true){
					$(".zhyelb li:eq(1)").append(data.zhxx.zhdh);
					$(".zhyelb li:eq(2)").append(data.zhxx.khmc);
					$(".zhyelb li:eq(3)").append();
					$(".zhyelb li:eq(4)").append(data.zhxx.cpmc);
					if(data.zhxx.ccy=="01"){
						$(".zhyelb li:eq(5)").append("人民币");
					}
					if(data.zhxx.chbz=="0"){
						$(".zhyelb li:eq(6)").append("钞");							
					}else if(data.zhxx.chbz=="1"){
						$(".zhyelb li:eq(6)").append("汇");
					}
					$(".zhyelb li:eq(7)").append(data.zhxx.zhye);
					$(".zhyelb li:eq(8)").append(data.zhxx.kyye);
					$(".zhyelb li:eq(9)").append(data.zhxx.khrq);
					$(".zhyelb li:eq(10)").append(data.zhxx.ckqx);
					$(".zhyelb li:eq(11)").append(data.zhxx.xcqx);
					if(data.zhxx.jlzt.trim()=="1"){
						$(".zhyelb li:eq(12)").append("有效");							
					}
				}
				
			},
			error:function(data){
				alert("456");
			}
		});
	}else if(uri=="/zzhk"){
		cardno="";
		$.ajax({
			url:systemUrl+"/Spring3HibernateMaven/yonghuziliao/tozzhk.mobile",
			type:"get",
			dataType:"json",
			success:function(data){
				if(data.flag==true){
					cardno=data.msg.zhdh;
					$(".kh").find("span.ui-btn-text").prepend(data.msg.zhdh+" "+data.msg.khmc);
					zhuanchuhuming=data.msg.khmc;
					$(".yue li:eq(0)").append(data.msg.yddh);
					if(data.zhxx.ccy=="01"){
							$(".yue li:eq(1)").append("人民币");
							bizhong="人民币";
					}
					$(".yue li:eq(2)").append(data.msg.zz_ed);
					rixiane=data.msg.zz_ed;
					$(".yue li:eq(3)").append(data.zhxx.kyye);
					keyongyue=data.zhxxkyye;
				}else{
					$(".kh").html(data.msg);
					$(".yue").empty();
				}
			},
			error:function(data){
				alert("789");
			}
		});
	}else if(uri=="/qrzz"){
		if(jiazaiflag==1){
			$("#zrzh").val(zhuanruzhanghao);
			if(zhuanzhangflag==0){
				$("#cd2 option").eq(0).attr("selected","true");
				changed($("#cd2"));
				gc();
			}else{
				$("#cd2 option").eq(1).attr("selected","true");
				changed($("#cd2"));
				gc();
				$("#s_bank").val(zhuanruyinhang);
				changed($("#s_bank"));
				$("#s_province").append("<option value='"+sheng+"' selected='selected'>"+sheng+"</option>");
				changed($("#s_province"));
				$("#s_city").append("<option value='"+shi+"' selected='selected'>"+shi+"</option>");
				changed($("#s_city"));
				$("#s_county").append("<option value='"+zhihang+"' selected='selected'>"+zhihang+"</option>");
				changed($("#s_county"));
			}
		}
	}else if(uri=="/zzhkqr"){
		if(zhuanzhangflag==0){
			$(".zhuanzhangxinxi li:eq(0)").append("同行转账");			
		}else{
			$(".zhuanzhangxinxi li:eq(0)").append("跨行转账");
		}
		$(".zhuanzhangxinxi li:eq(1)").append(bizhong);
		$(".zhuanzhangxinxi li:eq(2)").append(zhuanchuhuming);
		$(".zhuanzhangxinxi li:eq(3)").append(zhuanruhuming);
		$(".zhuanzhangxinxi li:eq(4)").append(cardno);
		$(".zhuanzhangxinxi li:eq(5)").append(zhuanruzhanghao);
		$(".zhuanzhangxinxi li:eq(6)").append(zhuanruyinhang);
		$(".zhuanzhangxinxi li:eq(7)").append(sheng+"、"+shi+"、"+zhihang);
		$(".zhuanzhangxinxi li:eq(8)").append(zhuanzhangjine);
		$(".zhuanzhangxinxi li:eq(9)").append(zhuanzhangyongtu);
		$(".zhuanzhangxinxi li:eq(10)").append(tianjiazhanghu);
	}else if(uri=="/zzhkcg"){
		zhuanruyinhang=encodeURIComponent(zhuanruyinhang);
		zhuanruhuming=encodeURIComponent(zhuanruhuming);
		sheng=encodeURIComponent(sheng);
		shi=encodeURIComponent(shi);
		zhihang=encodeURIComponent(zhihang);
		zhuanzhangyongtu=encodeURIComponent(zhuanzhangyongtu);
		$.ajax({
			url:systemUrl+"/Spring3HibernateMaven/yonghuziliao/zzcg.mobile",
			type:"post",
			data:{"zhuanzhangflag":zhuanzhangflag,"zhdh":cardno,"pwd":zhuanzhangmima,"jyje":zhuanzhangjine,"skrzh":zhuanruzhanghao,"zhuanruhuming":zhuanruhuming,"shoukuanhang":zhuanruyinhang,"zhihang":zhihang,"chengshi":sheng+shi,"zhuanzhangyongtu":zhuanzhangyongtu},
			success:function(data){
				if(data.flag==false){
					alert(data.msg);
				}else{
					if(zhuanzhangflag==0){
						$(".zzcg li:eq(0)").append("同行转账");			
					}else{
						$(".zzcg li:eq(0)").append("跨行转账");
					}
					$(".zzcg li:eq(1)").append(bizhong);
					$(".zzcg li:eq(2)").append(zhuanchuhuming);
					$(".zzcg li:eq(3)").append(decodeURI(zhuanruhuming));
					$(".zzcg li:eq(4)").append(cardno);
					$(".zzcg li:eq(5)").append(zhuanruzhanghao);
					$(".zzcg li:eq(6)").append(decodeURI(zhuanruyinhang));
					$(".zzcg li:eq(7)").append(decodeURI(sheng)+"、"+decodeURI(shi)+"、"+decodeURI(zhihang));
					$(".zzcg li:eq(8)").append(zhuanzhangjine);
					$(".zzcg li:eq(9)").append(decodeURI(zhuanzhangyongtu));
					$(".zzcg li:eq(10)").append(tianjiazhanghu);
				}
			},
			error:function(data){
				alert("请求失败");
			}
		});
	}
	});


$(document).on("pagebeforecreate","#cyzhgl",function(data){
	var test="";
	$.ajax({
		url:systemUrl+"/Spring3HibernateMaven/yonghuziliao/findlxr.mobile",
		type:"get",
		dataType:"json",
		async:false,
		success:function(data){
			if(data.flag==true){
				$.each(data.list,function(i,value){
						var test1="<div data-role='collapsible'> <h3 class='lxr'>"+
						value.shoukuanzhanghao+" "+value.zhanghuhuming+
						"</h3> <ul data-role='listview' class='yh'> <li data-icon='false'>转入银行："+
						value.zhuanruyinhang+
						"</li> <li data-icon='false'><a href='qrzz.html' style='color:#ff0000; text-align:center;' onClick='choose("+
						"\""+value.shoukuanzhanghao+ "\""+","+"\""+value.zhanghuleixing+"\""+","+"\""+value.zhanghuhuming+"\""+","+"\""+value.zhuanruyinhang+"\""+","+"\""+value.sheng+"\""+","+"\""+value.shi+"\""+","+"\""+value.zhihang+"\""+
						");'>选择</a></li> </ul> </div>";
						test+=test1;
				});
			}
		},
		error:function(data){
			alert("321");
		}
	});
	$("#lxrlb").append(test);
});
$(document).on("pageremove",function(data){
	jiazaiflag=0;
});


function choose(skzh,zhlx,zhhm,zryh,province,city,county){
	jiazaiflag=1;
	zhuanruzhanghao=skzh;
	zhuanruhuming=zhhm;
	if(zhlx=="同行转账"){
		zhuanzhangflag=0;
	}else{
		zhuanzhangflag=1;
		zhuanruyinhang=zryh;
		sheng=province;
		shi=city;
		zhihang=county;
	}
}

function changed(obj){
	var selected=obj.find("option:selected").text();
 	obj.prev().find(".ui-btn-text").text(selected);
}

function queren(){
	zhuanruzhanghao="";
	zhuanzhangflag=0;
	zhuanzhangjine="";
	zhuanzhangyongtu="";
	zhuanruyinhang="";
	sheng="";
	shi="";
	zhihang="";
	tianjiazhanghu="";
	zhuanruzhanghao=$("#zrzh").val();
	if($("#cd2").val()=="同行转账"){
		zhuanzhangflag=0;
	}else{
		zhuanzhangflag=1;
	}
	zhuanzhangjine=$("#zzje").val();
	zhuanzhangyongtu=$("#zzyt").val();
	zhuanruyinhang=$("#s_bank").val();
	sheng=$("#s_province").val();
	shi=$("#s_city").val();
	zhihang=$("#s_county").val();
	if($("#switch").val()=="on"){
		tianjiazhanghu="是";
	}else{
		tianjiazhanghu="否";
	}
}

function login(){
	if(cardno==""){
		$.mobile.changePage("denglu.html","slipe");		
		return false
	}
	return true;
}
